/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package deti.es.ukni.persistence.entity;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author eurico
 */
@Entity
@Table(name = "COMMENT_EVENT")
@NamedQueries({@NamedQuery(name = "CommentEvent.findAll", query = "SELECT c FROM CommentEvent c"), @NamedQuery(name = "CommentEvent.findByRefidcomment", query = "SELECT c FROM CommentEvent c WHERE c.commentEventPK.refidcomment = :refidcomment"), @NamedQuery(name = "CommentEvent.findByRefidaccount", query = "SELECT c FROM CommentEvent c WHERE c.commentEventPK.refidaccount = :refidaccount"), @NamedQuery(name = "CommentEvent.findByRefidevent", query = "SELECT c FROM CommentEvent c WHERE c.commentEventPK.refidevent = :refidevent")})
public class CommentEvent implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CommentEventPK commentEventPK;
    @JoinColumn(name = "REFIDACCOUNT", referencedColumnName = "IDACCOUNT", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Account account;
    @JoinColumn(name = "REFIDCOMMENT", referencedColumnName = "IDCOMMENT", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Comment comment;
    @JoinColumn(name = "REFIDEVENT", referencedColumnName = "IDEVENT", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Event event;

    public CommentEvent() {
    }

    public CommentEvent(CommentEventPK commentEventPK) {
        this.commentEventPK = commentEventPK;
    }

    public CommentEvent(int refidcomment, int refidaccount, int refidevent) {
        this.commentEventPK = new CommentEventPK(refidcomment, refidaccount, refidevent);
    }

    public CommentEventPK getCommentEventPK() {
        return commentEventPK;
    }

    public void setCommentEventPK(CommentEventPK commentEventPK) {
        this.commentEventPK = commentEventPK;
    }

    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

    public Comment getComment() {
        return comment;
    }

    public void setComment(Comment comment) {
        this.comment = comment;
    }

    public Event getEvent() {
        return event;
    }

    public void setEvent(Event event) {
        this.event = event;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (commentEventPK != null ? commentEventPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CommentEvent)) {
            return false;
        }
        CommentEvent other = (CommentEvent) object;
        if ((this.commentEventPK == null && other.commentEventPK != null) || (this.commentEventPK != null && !this.commentEventPK.equals(other.commentEventPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "deti.es.ukni.persistence.entity.CommentEvent[commentEventPK=" + commentEventPK + "]";
    }

}
